<?php
include('../../inc/global.inc');
include("../islogin.php");

    function lasturl()  //后台使用
    {
        $url = $_SERVER["HTTP_REFERER"];
        if(!$url)
        {
            $url="index.php";
        }
        return $url;
    }

    function jsURL($url,$text="操作成功!")  //后台使用
    {
        header("Content-Type:text/html; charset=utf-8");
        echo '<script>alert("'.$text.'");location.href="'.$url.'"</script>';
        exit;
    }

	$url = lasturl();

	if($_POST['t'])
	{
		$checked=1;
	}
	else if($_POST['n'])
	{
		$checked=0;
	}
	else
	{
		$checked=2;
	}

$ids = implode(',',$_POST["id"]);
$sql = "update product set p_sh=".$checked.",p_cl=1 where id in(".$ids.")";

//echo $sql;
$re = mysql_query($sql);
$re?jsURL($url,"操作成功".count($_POST["id"])."条"):jsURL($url,"操作失败,联系管理员");
//jsURL($url,$ids);
?>
